home *** CD-ROM | disk | FTP | other *** search
- Path: maths.tcd.ie!not-for-mail
- From: dwmalone@maths.tcd.ie (David Malone)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Must I free my linked lists? (GCC)
- Date: 22 Jan 1996 09:59:57 -0000
- Organization: Dept. of Maths, Trinity College, Dublin, Ireland.
- Message-ID: <4dvn6t$lc3@hamilton.maths.tcd.ie>
- References: <4dudic$aif@vixen.cso.uiuc.edu> <4dusp9$7k3@senator-bedfellow.MIT.EDU>
- NNTP-Posting-Host: hamilton.maths.tcd.ie
-
- rid@red-branch.MIT.EDU (Shawna Grimm) writes:
-
- >Unknown (Dannyman@uiuc.edu) typed in the following on 21 Jan 1996 22:09:16 GMT:
- >: I'm writing a program that makes use of dynamic memory allocation through
- >: linked lists using malloc() ... from an implementation PoV there's no need
- >: to flush this stuff as after the queue is created it's output and the
- >: program exits. My question is;
-
- >Yes, you _should_ free any memory that you allocate in your program.
- >Memory that is allocated and not freed will not be returned to the system
- >unless you turn the machine off, so if you want your memory back, you
- >must free it. Personally, I would prefer to use AllocMem() or AllocVec()
- >(with FreeMem() and FreeVec() ofcourse).
-
- I think the memory is freed in when you use malloc - in gcc or SAS/C.
- Weither this is in malloc's spec is another matter. I think
- memory you malloc ( as opposed to AllocMem'ed ) seems to be tracked
- and freed at exit. I noticed this when I was testing something I was
- writing on unix, and hadn't finished the memory stuff. It allocates
- about 8MB, which went fine, but I was quite shoked to see that I could
- run it twice in a row ( I only have 10MB of ram ).
-
- David.
-